import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'dart:math' as math;

import 'package:untitled/Page/local_map/custom_drawer.dart';
import 'package:untitled/font/mine_font.dart';

class AnchorPoint extends StatefulWidget {
  @override
  _AnchorPointState createState() => _AnchorPointState();
}

class _AnchorPointState extends State<AnchorPoint>
    with SingleTickerProviderStateMixin {
  late AnimationController _controller;
  final CustomDrawerController drawerController =
      Get.put(CustomDrawerController());
  @override
  void initState() {
    super.initState();
    _controller = AnimationController(
      vsync: this,
      duration: Duration(milliseconds: 1000),
    );
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return AnimatedBuilder(
        animation: _controller,
        builder: (context, child) {
          return Transform.translate(
            offset: Offset(
                0, math.sin(_controller.value * math.pi * 2) * 6), // 调整振幅和速度
            child: child,
          );
        },
        child: Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Icon(MineFont.anchor,
                color: Color.fromARGB(255, 69, 117, 246), size: 36),
            Obx(() {
              if (drawerController.playing.value) {
                _controller.repeat(reverse: true);
              } else {
                _controller.stop();
              }
              return Container();
            })
          ],
        ));
  }
}
